Skip to content

feat(language): a dimension's members are read by name - #8

Draft
FBumann wants to merge 14 commits into
compare/tuple-strictfrom
compare/multi-dims
Draft

FBumann wants to merge 14 commits into
compare/tuple-strictfrom
compare/multi-dims

Conversation

@FBumann

@FBumann FBumann commented Nov 17, 2026 •

Copy link
Copy Markdown

Prompt: Can you update my fork and do stacked PRs there comparing that? bsed on the alias or maps PR?

Prompt (follow-ups): SHow what #8 changes in its PR!! it should be stacked onto 9 · Github can change the head branch · Yes, restack it onto #8

Note

The following content was generated by AI.

#8's design as sugar over #9. Four refusals of #9 become the spelling each stood for; every spec #9 loads builds the same program here.

Draft, for comparison, not for merge. Stacked on #9 (compare/tuple-strict). Sibling: #7 (Confine).

1. A member operand meets the tuple by name

# #9
port_limit: { dims: [connection, period], expression: "flow <= at(capacity, by=connection[unit])" }
# here
port_limit: { dims: [connection, period], expression: "flow <= capacity" }

2. over=<member> sums the tuple, grouped by the members it leaves

# #9
split: { dims: [unit, period], expression: "sum(flow, over=connection, by=connection[unit]) == output" }
# here
split: { dims: [unit, period], expression: "sum(flow, over=port) == output" }

TIMES balance (examples/times/trade.yaml): sum(ire_flo * export, over=top_ire, by=top_ire[commodity, region]) → sum(ire_flo * export, over=[from_commodity, from_region, process]).

3. Two tuples that share a member join on it

# #9 (examples/times/capacity.yaml)
act: { dims: [region, vintage, period, process, timeslice], where: "prc_ts AND rtp_vintyr" }
# here
act: { dims: [prc_ts, rtp_vintyr] }

4. A step along a member

# #9
output: { dims: [unit, period], where: active }
# here
output: { dims: [active] }
# ramp_up keeps: output - shift(output, along=period, offset=1) <= ramp

The one non-sugar change

A parameter over two tuples that share a member (or stepped along one) carries those tuples as its new Parameter.domain. A tool refuses its stray data row there, where #9's where: drops it.

Inherited from #9, not re-shown

No relations:; a tuple's bare name as a condition; tuples of one member; dims: as the domain; mappings:.

Method, gate output, what was not done

Method

Gate (no pixi here; uv venv with the pinned tools)

  • lint pieces: ruff check, ruff format --check, pyrefly check (0 errors), prettier --check, typos, reuse lint, git diff --check. All pass. Not run: taplo, zizmor, lefthook itself.
  • pytest -q -n auto: 4255 passed, 3 skipped.
  • python -m zensical build --strict: no issues.
  • python -m tools.render_tex: 62 specs rendered.
  • compile-tex: not run. tectonic is not installed here.

Not done, or not carried over from the old #8

🤖 Generated with Claude Code

https://claude.ai/code/session_018B3nA494URRSeWy6wmELGP

claude and others added 10 commits November 16, 2026 16:40
`relations:` is `sets:`. A set named in the `dims:` of a parameter, a
variable or a constraint, or in `over=`, stands for its dimensions at the
combinations it lists: the entry has coordinates only there, and a tool
refuses a data row of a parameter anywhere else. There is no `in:` key.
A set's bare name in the `where:` of such an entry is refused, with the
set in `dims:` as the rewrite.

In math a sum or an index ranges over a set, so the construct that
`dims:` and `over=` take is named a set.

Co-Authored-By: Fabian Hofmann <fab.hof@gmx.de>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
An entry over a dimension twice, as TIMES' IRE_FLO: the alias's docs
example names the set in dims:, a test states IRE_FLO in this spelling,
and a set with two columns over one dimension is refused with an alias as
the rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
`in:` was answered "Did you mean 'in_'?", the field the load fills from
`dims:` and a file may not write. The suggestion now leaves it out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
The TIMES examples in this PR's spelling: sets: in place of relations:,
act over [prc_ts, rtp_vintyr], and ire_flo, trade_cost and export over
the set top_ire.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
sparse.yaml in this PR's spelling: sets:, and every entry over a set
names it in dims:. Restating balance found that over= a set beside by=
was refused; a set in over= now stands for its dimensions there too,
with the failing test first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
…pare/multi-dims

# Conflicts:
#	docs/examples/times/trade.md
#	examples/times/trade.yaml
The `sets:` section goes. A multi-dim is an entry under `dimensions:` with
`over:`, the spelling datarecord uses, and `maps:` keys it as it keys a
dimension. In `dims:` and `over=` it stands for its members, and two
multi-dims in one `dims:` join on the members they share. A multi-dim has
no `missing:`: a combination with no row is not one of its labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1Y7i5TWDbh9SKx86i
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1Y7i5TWDbh9SKx86i
A multi-dim in the `dims:` of a named expression or a `given:` entry now
stands for its members, as it does on a parameter, a variable and a
constraint, so every rule that compares `dims:` compares the members. A
multi-dim may have one member, a subset of that dimension. Its bare name
is a test in a constraint's `where:`, a named condition and a `when:`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1Y7i5TWDbh9SKx86i
Four refusals of #9 become the spelling each one stood for:

- an operand over a member meets the dimension: read at each tuple, as
  at(x, by=dimension[member]) reads it;
- sum(x, over=member) on an operand over the dimension: the sum through
  the dimension, grouped by the members over= leaves;
- two dimensions in one dims: that share a member: the entry over the
  members, where: the dimensions;
- a step along a member: the entry it steps in, and the entry it steps,
  over the members, where: the dimension.

Every spec #9 loads builds the same program. A parameter over the
members carries the tuples as its domain, where a tool refuses a stray
row; that is the one change no #9 spelling states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA494URRSeWy6wmELGP
…strict

The tree is the restack's: #8's design as the four lifts over #9. The
second parent keeps #8's earlier history, so the push fast-forwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA494URRSeWy6wmELGP
@FBumann FBumann changed the title feat(language)!: a multi-dim is a dimension with over: feat(language): a dimension's members are read by name Nov 17, 2026
@FBumann
FBumann changed the base branch from feat/dimension-alias to compare/tuple-strict November 17, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants